package com.anli.config;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author: LI-CI-GAO
 * 作者: licigao
 * 日期: 2021/8/30  19:30
 * 描述:
 */

@Component
public class MyExpireEventHandler extends KeyExpirationEventMessageListener {


    public MyExpireEventHandler(@Qualifier("expireMessageListener") RedisMessageListenerContainer listenerContainer) {
        super(listenerContainer);
    }

    @Override
    @Async("testpool")
    public void onMessage(Message message, byte[] pattern) {

        String key = new String(message.getBody());

        System.out.println("========>"+key);

    }
}
